{% extends "publisher/_publisher_layout.html" %}

{% block meta_title %}
Releases and revision history for {% if snap_title %}{{ snap_title }}{% else %}{{ snap_name }}{% endif %}
{% endblock %}

{% block content %}
<div id="main-content" class="u-no-margin--top">
  {% set selected_tab='release' %}
  {% include "publisher/_header.html" %}

  <section class="p-strip is-shallow">
    <div id="release-history">
      {% if release_history["error-list"] %}
        <div class="row">
          <div class="p-notification--negative">
            <p class="p-notification__response">
              {% for error in release_history["error-list"] %}
                <b>{{ error.code }}:</b> {{ error.message }}<br />
              {% endfor %}
            </p>
          </div>
        </div>
      {% endif %}
    </div>
  </section>
</div>

{% endblock %}

{% block scripts_includes %}
  <script src="{{ static_url('js/dist/release.js') }}" defer></script>
{% endblock %}

{% block scripts %}
  {% if "error-list" not in release_history %}
    <script>
      window.addEventListener("DOMContentLoaded", function() {
        Raven.context(function () {
          snapcraft.release.initReleases('#release-history',
            {{ snap_name|tojson }},
            {{ release_history|tojson }},
            {{ channel_maps_list|tojson }},
            {
              defaultTrack: {% if default_track %}{{ default_track|tojson }}{% else %}"latest"{% endif %},
              csrfToken: {{ csrf_token()|tojson }}
            }
          );
        });
      });
    </script>
  {% endif %}
{% endblock %}
